package com.qyc.Microservice.dto.result;

import java.io.Serializable;

import lombok.Data;

@Data
public class Result implements Serializable{

	private static final long serialVersionUID = 1L;

	private Integer status;
	
	private String message;
	
	private Object data;
	
	public Result() {
	}
	
	public void setResultCode(ResultCode resultCode) {
		this.status = resultCode.status();
		this.message = resultCode.message();
	}
	
	//返回成功
	public static Result success() {
		Result result = new Result();
		result.setResultCode(ResultCode.SUCCESS);
		return result;
	}
	
	//返回成功
	public static Result success(Object data) {
		Result result = new Result();
		result.setResultCode(ResultCode.SUCCESS);
		result.setData(data);
		return result;
	}
	
	//返回失败
	public static Result failure(ResultCode resultCode) {
		Result result = new Result();
		result.setResultCode(resultCode);
		return result;
	}
	
	//返回失败
	public static Result failure(ResultCode resultCode,Object data) {
		Result result = new Result();
		result.setResultCode(resultCode);
		result.setData(data);
		return result;
	}
}
